package string;

import java.util.Scanner;

public class Change1024 {
	
	//Money:1024,64,16,4,1
	public int changeMoney(int price) {
		int num = 0;
		int maxChange = 64;
		int change = 1024 - price;
		while(change > 0) {
			num = num + change/maxChange;
			change = change%maxChange;
			maxChange = maxChange/4;
		}
		return num;
	}
	
	public static void main(String[] args) {
		Change1024 change = new Change1024();
		Scanner in = new Scanner(System.in);
		int price = 0;
		int num = 0;
		while(in.hasNext()) {
			price = in.nextInt();
			num = change.changeMoney(price);
			System.out.println(num);
		}
		in.close();
	}
}
